package statusmanage

import confv1beta1 "gopkg.openfuyao.cn/bkecommon/cluster/api/v1beta1"

type StatusRecord struct {
	CurrentClusterState confv1beta1.ClusterHealthState
	LatestFailedState   string
	LatestNormalState   string
	StatusCount         int
	NeedRequeue         bool
}

func (r *StatusRecord) Inc() {
	r.StatusCount++
}

func (r *StatusRecord) Dec() {
	r.StatusCount--
}

func (r *StatusRecord) Reset() {
	r.StatusCount = 0
	r.LatestFailedState = ""
}
func (r *StatusRecord) Equal(state string) bool {
	return r.LatestFailedState == state
}

func (r *StatusRecord) AllowFailed() bool {
	return r.StatusCount < ReconcileAllowedFailedCount
}

func (r *StatusRecord) SetLatestFailedState(state string) {
	r.LatestFailedState = state
}

func (r *StatusRecord) SetLatestNormalState(state string) {
	r.LatestNormalState = state
}

func (r *StatusRecord) SetCurrentClusterState(state confv1beta1.ClusterHealthState) {
	r.CurrentClusterState = state
}
